﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace SiteMapEditor.Forms
{
    public partial class AddXmlForm : Form
    {
        public XmlNode AddedXmlNode { get; set; }

        public AddXmlForm()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(this.textBox1.Text);

                this.AddedXmlNode = doc.DocumentElement;

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception error)
            {
                MessageBox.Show(this, "Error while parsing Xml: " + error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.AddedXmlNode = null;
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}
